﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QStackedWidget>
#include <QTimer>
#include <QWidget>
#include <QMouseEvent>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QProgressBar>

#include "Window/u_menubar.h"
#include "Window/u_statusbar.h"
#include "Window/u_mainpage.h"
#include "Window/qwe.h"
#include "../Console/Task/TaskReceiver.h"
#include "Window/System/realtimedata.h"
#include "../Console/Server/SerialPort.h"
#include "agreement.h"

#define RED "min-width:20px;min-height:20px; max-width:20px;max-height:20px;border-radius:10px;border:1px solid black;background:red;"
#define WHITE "min-width:20px;min-height:20px; max-width:20px;max-height:20px;border-radius:10px;border:1px solid black;background:rgba(100,100,140);"
#define GREEN "min-width:20px;min-height:20px; max-width:20px;max-height:20px;border-radius:10px;border:1px solid black;background:rgba(0,255,0);"
#define GREEN1 "background: rgba(0,255,0); font-size:17px;padding: 4px 0 0 0px;"
#define PRO  "QProgressBar{border: none solid grey;border-radius: 1px;background-color:rgb(245,245,245);} QProgressBar::chunk{background:rgb(100,100,140);}"
#define FONT "font-size:12pt; font-weight:600; color:rgba(100,100,140);"

# pragma execution_character_set("utf-8")
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void showEvent(QShowEvent *event);
    void paintEvent(QPaintEvent *event);
void UpdataData();
void ClearData();

signals:
void updatePoint(float speed);
void updatePoint_2(float speed);
void updatePoint_3(float speed);
void updatePoint_4(float speed);

public slots:
bool eventFilter(QObject *watched, QEvent *event);
    void showData();
    void showData_JX();
    void showData_ZY1();
    void showData_ZY2();
    void clearData();
    void showWidget_JX1();
    void showWidget_JX2();
    void showwidget_Zy1();
    void showWidget_ZY2();
    void LightChange(int a);
    void LightChange1(int a);
    void workState(bool a);
    void workState1(bool a);
private:
    void         InitWidget();
    void         SetupConnections();
    void         Initialize();
    void         mousePressEvent(QMouseEvent *event);
    void         mouseMoveEvent(QMouseEvent *event);

    SerialPort      *portJX_1;
//    SerialPort     *portJX_2;
//    SerialPort     *portZY_1;
//    SerialPort     *portZY_2;
    QWidget         *parent;
    MenuBar         *menuBar;
    StatusBar       *statusBar;
    QStackedWidget  *stackedWidget;
    QPoint          startPos;
    QPoint          startPos1;
    bool            twink=false;
    bool            off_1=false;
    bool            off_2=false;
    bool            off_3=false;
    bool            off_4=false;


    GlobalData *globalData;
    QTimer* timer;
    QTimer* timer1;
    Ui::MainWindow  *ui;
};

#endif // MAINWINDOW_H
